﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CarrContact.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <script type='text/javascript' src="assets/js/Carrs.js"></script>
    <script type='text/javascript' src="assets/js/Ports.js"></script>
    <link rel="stylesheet" href="Assets/css/EditTableCell.css" type="text/css" />
    <script type='text/javascript' src="Assets/js/jquery-custom-1.0.0.js?v=0611"></script>
    <script type='text/javascript' src="Assets/js/CarrContact.js?v=0.2"></script>
    <script type='text/javascript' src="Assets/Js/encoder.js"></script>
    <script type="text/javascript">
        var nPermissions = '<%=nPermissions %>';
        function getUrlVars() {
            var vars = {};
            var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
                vars[key] = value;
            });
            return vars;
        }
        function doDelete(strID, strName) {
            if (confirm('Bạn có thực sự muốn xóa ' + strName + '?')) {
                var vnpage = getUrlVars()["page_number"];
                var vChar = getUrlVars()["letter"];
                var strHref = "";
                if (vnpage)
                    strHref = "CarrContact.aspx?action=delete&ID=" + strID + "&page_number=" + vnpage;
                else
                    strHref = "CarrContact.aspx?action=delete&ID=" + strID;
                if (vChar)
                    window.location.href = strHref + "&letter=" + vChar;
                else
                    window.location.href = strHref;
            }
        }
        function doEdit(strID, strName) {
            var vnpage = getUrlVars()["page_number"];
            var vChar = getUrlVars()["letter"];
            var strHref = "";
            if (vnpage)
                strHref = "CarrContact.aspx?action=edit&ID=" + strID + "&page_number=" + vnpage;
            else
                strHref = "CarrContact.aspx?action=edit&ID=" + strID;
            if (vChar)
                window.location.href = strHref + "&letter=" + vChar;
            else
                window.location.href = strHref;
        }
        function OpenCustomer(sender, url) {
            if (!($(sender).parent().hasClass("editing") || $("#btnupdate").val() == "Done") && $(sender).text() != "") {
                window.open(url, "customer", "width=1100,height=600,top=0,toolbar=no,directories=no,location=no,menubar=no,status=no");
            }
        }
        function doDeleteNotices(strID) {
            if (confirm('Bạn có thực sự muốn xóa ?')) {
                window.location.href = "CarrContact.aspx?action=deleteNotice&noticeID=" + strID;
            }
        }
        $().ready(function () {
            $('#txtCarrier').focus().autocomplete(carrs, { matchContains: true });
            //$('#txtPort').focus().autocomplete(ports);
            //$('#txtPort').focus().autocomplete(ports, { matchContains: true });
            var nsuperAdmin = '<%Response.Write(nPermissions.ToString()); %>'
            if (nsuperAdmin < 9) $('#slAll').hide();
            var vID = getUrlVars()["ID"];
            if (vID)
                $("#addnewbox").show();
        });
    </script>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <%--<h2>CHI TIẾT LIÊN HỆ HÃNG TÀU</h2>
            <div class="clear">
            </div>--%>
            <div class="content-box">
                <form id="frmCarrContact" runat="server" autocomplete="off">
                <%if (nPermissions >= 3)
                      { %>
                <div id="addnewbox" style="display: none;">
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">
                            LIÊN HỆ HÃNG TÀU: Add [Edit]</h3>
                        <div class="clear">
                        </div>
                    </div>
                    <table class="adminedit" style="width: 100%;">
                        <tr>
                            <th align="center">
                                Carrier
                            </th>
                            <th align="center">
                                Location
                            </th>
                            <th align="center">
                                Port
                            </th>
                            <th align="center">
                                PIC-SALES
                            </th>
                            <th align="center" colspan="2">
                                Charge
                            </th>
                            <th align="center">
                                ADV
                            </th>
                            <th align="center">
                                Tel
                            </th>
                            <th align="center">
                                Cell
                            </th>
                            <th>
                                Skype
                            </th>
                            <th align="center">
                                Email
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox class="cls" ID="txtCarrier" runat="server" Width="150px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:DropDownList class="cls" ID="ddLocation" runat="server" Width="105px">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtPort" runat="server" Width="100px" TabIndex="3"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtPICSALES" runat="server" Width="75px" TabIndex="4"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtCharge" runat="server" Width="70px" TabIndex="5"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtCharge1" runat="server" Width="70px" TabIndex="6"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>
                            <%-- <td>
                                <asp:TextBox class="cls" ID="txtRoute" runat="server" Width="100px" TabIndex="7"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>--%>
                            <td>
                                <asp:TextBox class="cls" ID="txtAdvantage" runat="server" Width="90px" TabIndex="7"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtTel" runat="server" Width="90px" TabIndex="8" Style="text-align: right;"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtCell" runat="server" Width="90px" TabIndex="9" Style="text-align: right;"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtSkype" runat="server" Width="100px" TabIndex="10"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtEmail" runat="server" Width="100px" TabIndex="11"
                                    Style="text-align: right;"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                    <asp:Label ID="lblerror" class="error" runat="server"></asp:Label>
                    <table class="paramlist admintable" width="100%">
                        <tr>
                            <td colspan="2">
                                <asp:Button class="button" ID="btnSave" runat="server" TabIndex="12" Text="Cập nhật"
                                    OnClick="btnSave_Click" />
                            </td>
                        </tr>
                    </table>
                </div>
                <%} %>
                <div class="content-box-header">
                    <h3 style="cursor: s-resize;">
                        CHI TIẾT LIÊN HỆ HÃNG TÀU</h3>
                    <asp:DropDownList ID="ddPicSales" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddPicSales_SelectedIndexChanged">
                    </asp:DropDownList>
                    &nbsp;
                    <asp:DropDownList ID="ddCarriers" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddCarriers_SelectedIndexChanged">
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddLocationSearch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddLocationSearch_SelectedIndexChanged">
                    </asp:DropDownList>
                    <%if (nPermissions > 3)
                          { %>
                    &nbsp;&nbsp;&nbsp;<input type="button" style="float: right; margin: 9px 10px;" class="button"
                        value="Edit" id="btnupdate" />
                    <input id="btnAddNew" type="button" style="float: right; margin: 9px 10px;" class="button"
                        value="Add new" />
                    <%} %>
                    <div class="clear">
                    </div>
                </div>
                <%if (nPermissions > 7)
                      { %>
                <%=strAlphaBet%>
                <%} %>
                <fieldset>
                    <asp:Repeater ID="rptData" runat="server">
                        <ItemTemplate>
                            <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'"
                                carrcontactid='<%#Eval("ID") %>'>
                                <td align="center">
                                    <%# DataBinder.Eval(Container.DataItem, "Index")%>
                                </td>
                                <td editable="true" code="Carr" completesource="carrs" style="font-weight: bold;">
                                    <%# DataBinder.Eval(Container.DataItem, "Carr") %>
                                </td>
                                <td code="LocationName">
                                    <%# DataBinder.Eval(Container.DataItem, "LocationName") %>
                                </td>
                                <td editable="true" code="Port">
                                    <%# DataBinder.Eval(Container.DataItem, "Port") %>
                                </td>
                                <td editable="true" code="Pic_Sales" style="text-decoration: underline; color: Blue;"
                                    onclick='OpenCustomer(this,"<%# GetCustomerLink(DataBinder.Eval(Container.DataItem, "ID"),DataBinder.Eval(Container.DataItem, "PicID")) %>")'>
                                    <%# DataBinder.Eval(Container.DataItem, "Pic_Sales") %>
                                </td>
                                <td editable="true" code="Charge">
                                    <%# DataBinder.Eval(Container.DataItem, "Charge")%>
                                </td>
                                <td editable="true" code="Charge1" style="min-width: 50px;">
                                    <%# DataBinder.Eval(Container.DataItem, "Charge1")%>
                                </td>
                                <%-- <td editable="true" code="Route">
                                    <%# DataBinder.Eval(Container.DataItem, "Route")%>
                                </td>--%>
                                <td editable="true" code="Advantage">
                                    <%# DataBinder.Eval(Container.DataItem, "Advantage") %>
                                </td>
                                <td editable="true" code="Tel">
                                    <%# DataBinder.Eval(Container.DataItem, "Tel") %>
                                </td>
                                <td editable="true" code="Cell">
                                    <%# DataBinder.Eval(Container.DataItem, "Cell") %>
                                </td>
                                <td editable="true" code="Skype">
                                    <%# DataBinder.Eval(Container.DataItem, "Skype") %>
                                </td>
                                <td editable="true" code="Email">
                                    <%# DataBinder.Eval(Container.DataItem, "Email")%>
                                </td>
                                <%if (nPermissions >= 3)
                                      { %>
                                <td>
                                    <div class="changed">
                                        <%# DataBinder.Eval(Container.DataItem, "Action")%>
                                    </div>
                                </td>
                                <%} %>
                            </tr>
                        </ItemTemplate>
                        <HeaderTemplate>
                            <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                                editcellcontent="true">
                                <thead>
                                    <tr style="background: #CCC;">
                                        <th align="center">
                                            Index
                                        </th>
                                        <th align="center">
                                            Carrier
                                        </th>
                                        <th align="center" width="80px">
                                            Location
                                        </th>
                                        <th align="center">
                                            Port
                                        </th>
                                        <th align="center">
                                            PIC-SALES
                                        </th>
                                        <th align="center" colspan="2">
                                            Phụ trách tuyến
                                        </th>
                                        <%-- <th align="center">
                                            Chuyên tuyến
                                        </th>--%>
                                        <th align="center">
                                            ADV
                                        </th>
                                        <th align="center">
                                            Tel
                                        </th>
                                        <th align="center">
                                            Cell
                                        </th>
                                        <th>
                                            Skype
                                        </th>
                                        <th align="center">
                                            Email
                                        </th>
                                        <%if (nPermissions >= 3)
                                              { %>
                                        <th align="center" width="75px">
                                            Action
                                        </th>
                                        <%} %>
                                    </tr>
                                </thead>
                        </HeaderTemplate>
                        <FooterTemplate>
                            </TABLE>
                        </FooterTemplate>
                    </asp:Repeater>
                </fieldset>
                <div class="clear">
                </div>
                <div id="footer">
                    <%=strPager%>
                </div>
                <asp:Panel ID="pnEditNotices" runat="server">
                    <b>NOTICES: &nbsp;&nbsp; &nbsp;</b><asp:TextBox ID="txtNotices" runat="server" Width="500px"></asp:TextBox>
                    <asp:Button class="button" ID="btnSaveNotices" runat="server" TabIndex="13" Text="Save"
                        OnClick="btnSaveNotices_Click" />
                    <asp:Label ID="Label1" CssClass="error" runat="server"></asp:Label><br />
                    <br />
                </asp:Panel>
                <asp:Repeater ID="rpNotices" runat="server">
                    <ItemTemplate>
                        <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'">
                            <td align="center" title="Index">
                                <%# DataBinder.Eval(Container.DataItem, "IndexNotices")%>
                            </td>
                            <td class="wrapword">
                                <%# DataBinder.Eval(Container.DataItem, "Notices")%>
                            </td>
                            <td align="center" title="Index">
                                <%# DataBinder.Eval(Container.DataItem, "User")%>
                            </td>
                            <td align="center" title="Index">
                                <%# DataBinder.Eval(Container.DataItem, "LastUpdate")%>
                            </td>
                            <%if (nPermissions >= 3)
                                  {%>
                            <td align="center">
                                <%# DataBinder.Eval(Container.DataItem, "Action")%>
                            </td>
                            <%} %>
                        </tr>
                    </ItemTemplate>
                    <HeaderTemplate>
                        <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist">
                            <thead>
                                <tr>
                                    <th align="center" width="75px">
                                        Index
                                    </th>
                                    <th class="wrapword">
                                        Notices
                                    </th>
                                    <th align="center" width="75px">
                                        User
                                    </th>
                                    <th align="center" width="75px">
                                        Update
                                    </th>
                                    <%if (nPermissions >= 3)
                                          {%>
                                    <th align="center" width="75px">
                                        Action
                                    </th>
                                    <%} %>
                                </tr>
                            </thead>
                    </HeaderTemplate>
                    <FooterTemplate>
                        </TABLE>
                    </FooterTemplate>
                </asp:Repeater>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
